﻿using System;
using System.Diagnostics;
using System.IO;

namespace EPPlus_ExcelDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputFilePath = "../../Documents/";
            string outputFilePath = @"Result\";
            string separatorLine = new string('-', 30);

            UpdateDirectory(outputFilePath);

            #region 1. Conversion

            Conversion.ConvertToCsv(inputFilePath + "Sample01.xlsx", outputFilePath + "ToCsv");
            Console.WriteLine("ConvertToCsv Finish.");

            Conversion.ConvertToImage(inputFilePath + "Sample02.xlsx", outputFilePath + "ToImage");
            Console.WriteLine("ConvertToImage Finish.");

            Conversion.ConvertToPdf(inputFilePath + "Sample02.xlsx", outputFilePath + "ToPdf.pdf");
            Console.WriteLine("ConvertToPdf Finish.");

            Conversion.ConvertToXls(inputFilePath + "Sample01.xlsx", outputFilePath + "ToXls.xls");
            Console.WriteLine("ConvertToXls Finish.");

            Conversion.ConvertToXml(inputFilePath + "Sample01.xlsx", outputFilePath + "ToXml.xml");
            Console.WriteLine("ConvertToXml Finish.");

            Console.WriteLine(separatorLine);

            #endregion

            #region 2. Miscellaneous

            Miscellaneous.InsertControl(inputFilePath + "Sample02.xlsx", outputFilePath + "Control.xlsx");
            Console.WriteLine("InsertControl Finish.");

            Miscellaneous.InsertObject(inputFilePath + "Sample04.xlsx", outputFilePath + "Object.xlsx");
            Console.WriteLine("InsertObject Finish");

            Miscellaneous.InsertSparklines(inputFilePath + "Sample02.xlsx", outputFilePath + "InsertSparklines.xlsx");
            Console.WriteLine("InsertSparklines Finish.");

            Miscellaneous.SaveChartToPicture(inputFilePath + "Sample03.xlsx", outputFilePath + "Chart");
            Console.WriteLine("SaveChartToPicture Finish.");

            #endregion

            Process.Start("explorer.exe", outputFilePath);
            Console.WriteLine("Press any key to quit");
            Console.ReadKey();

        }



        static void UpdateDirectory(string path)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }
    }
}
